<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="icon" href="data:;base64,=">
<title>12306验证码识别</title>
<meta name="keywords" content="12306,12306抢票,抢票软件,云抢票,抢票平台,专业抢票,分流抢票,火车抢票,黄牛抢票软件,在线抢票,黄牛,12306验证码识别,12306接口,吾易抢票,心蓝抢票,斗鱼抢票">
<meta name="description" content="12306,12306抢票,抢票软件,云抢票,抢票平台,专业抢票,分流抢票,火车抢票,黄牛抢票软件,在线抢票,黄牛,12306验证码识别,12306接口,吾易抢票,心蓝抢票,斗鱼抢票">
</head>
<body>
<h1>12306验证码识别</h1>
<div class="img" style="position: relative;">
<img alt="" src="" id="img">
</div>
 <button id="btnGetImg" onClick="getImg();" type="button">刷新图片</button>
<input type="button" value="识别" onclick="img_vcode()" />
<div id="error"></div>
<div id="msg"></div>

  <hr>
    <div>
        <span>实时并发:</span>
        <span id="qps" style="color:red">0/s</span>
        <span>最高并发:</span>
        <span id="max" style="color:red">0/s</span>
        <span >(理论峰值1000/s，不限次数)</span>
        <span >今日累计调用:</span>
        <span id="times" style="color:red">0</span>
        <span >温馨提醒:早六点到七点高峰期,不太稳定，服务器可能会延迟响应</span>
    </div>
    <hr>
<div style="padding-top: 30px;">免责声明：

<p>1. 本服务并不针对任何人,任何机构,任何网站。</p>

<p>2. 本服务仅用于个人学习图像识别技术，图片打标签，文字识别研究等，请勿用于非法用途。</p>
<p>若因使用本服务引起各类民事，刑事纠纷，属服务使用者的个人行为，与本服务作者无关。</p>

<p>3. 从你开始使用本服务，默认接受使用条款.</p></div>

</body>
<script type="text/javascript" src="https://s5.cnzz.com/z_stat.php?id=1276767139&web_id=1276767139"></script>
<script type="text/javascript" src="https://cdn.jiedanba.cn/lib/jquery/1.8.3/jquery.min.js"></script>

<script type="text/javascript">

$(function(){
	getImg();
})
var base64;
function getImg() {
	 $("#01").remove();
	 $("#11").remove();
	 $("#21").remove();
	 $("#31").remove();
	 $("#41").remove();
    $.ajax({
        url: 'https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand&'+Math.random(),
        type: "get",
        dataType: 'jsonp',
        contentType: "application/json",
        success: function (res) {
            if(res.result_code) {
                $("#img").attr("src","data:img/jpg;base64,"+res.image);
                base64 = res.image;
            }else{
                alert(res.result_message);
            }
        }
    });
}

function img_vcode(){

	 $.ajax({
	        url: '#(ctx)/api/v2/img_vcode',
	        data:{'base64':base64},
	        type: "post",
	        success: function (result) {
	        	var dataObj=eval("("+result+")");
	        	//var r = result.res;
	        	
	        	 if(dataObj.res==''){
	        		 alert("识别错误");
	        	 }
	        	 $("#01").remove();
	        	 $("#11").remove();
	        	 $("#21").remove();
	        	 $("#31").remove();
	        	 $("#41").remove();
	        	 $("#error").text("识别成功，坐标："+result);
	        	 var r = dataObj.res.split("),");
	 			 console.log(r)
	        	  for(var i = 0 ; i < r.length; i++){
	        		$(".img").append('<img src="#(ctx)/assets/img/choose_ic.png"  id='+Number(i)+Number(1)+'>');
	        		  var reg = new RegExp("\\(","g")
	        		  var reg2 = new RegExp("\\)","g")
	        		  var temp = r[i];
	        		  temp = temp.replace(reg, "");
	        		  temp = temp.replace(reg2, "");
	        		  var xy = temp.split(",");
	        		  console.log(xy)
	        		 $("#"+i+1).css("position","absolute");
	        		 $("#"+i+1).css("left",xy[0]+"px");
	        		
	        		 $("#"+i+1).css("top",Number(xy[1])+Number(14)+"px");
	        		 $("#"+i+1).css("width","27px");
	        		 $("#"+i+1).css("height","27px");
	        	  }
	        	  
	        	  var reg = new RegExp("\\(","g")
	    		  var reg2 = new RegExp("\\)","g")
	        	  var checkxy = dataObj.res.replace(reg, "");
	        	  checkxy =  checkxy.replace(reg2, "");
	        	  $.ajax({
	        	        url: 'https://kyfw.12306.cn/passport/captcha/captcha-check?rand=sjrand&login_site=E&_=1550132434006'+Math.random()+"&answer="+checkxy,
	        	        type: "get",
	        	        dataType: 'jsonp',
	        	        contentType: "application/json",
	        	        success: function (res) {
	        	        	 $("#msg").text("12306返回信息："+res.result_message)
	        	        }
	        	    });
	        }
	    });
}

</script>
</html>